package com.marchsoft.controller;

import com.marchsoft.domain.Comm;
import com.marchsoft.service.ICommService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.io.UnsupportedEncodingException;
import java.util.List;

/**
 * class description：
 * author：rsw
 * Date: 2019/11/17
 * Time: 9:17
 **/
@RestController
@RequestMapping("comm")
public class CommController {

    @Autowired
    private ICommService commService;

    /**
     * @throws UnsupportedEncodingException
     * 查询所有会议内容
     */
    @RequestMapping("/list")
    public ResponseEntity<List<Comm>> findAll() throws UnsupportedEncodingException {
        return ResponseEntity.ok(commService.findAll());
    }

    /**
     * 根据会议记录id查询一条会议记录
     * @param cid 会议记录id
     * @return 一条会议记录
     */
    @RequestMapping("/query-one")
    public ResponseEntity<Comm> queryCommByCid(Integer cid){
        return ResponseEntity.ok(commService.queryCommByCid(cid));
    }

    /**
     *
     * @param comm
     * @return
     * 提交会议
     */
    @RequestMapping(value="/save", method= RequestMethod.POST)
    public ResponseEntity<Boolean> insertComm(Comm comm){
        comm.setTime(System.currentTimeMillis());
        return ResponseEntity.ok(commService.insertComm(comm));
    }

}


